"Organized by Fabio
if exists("b:__PHP_XPT_VIM__")
  finish
endif
let b:__PHP_XPT_VIM__ = 1

" containers
let [s:f, s:v] = XPTcontainer()

" inclusion
XPTinclude
    \ _common/common
    \ _condition/c.like
    \ _comment/c.like

" ========================= Function and Variables =============================

call extend(s:v, { '$TRUE': 'TRUE'
                \, '$FALSE': 'FALSE'
                \, '$NULL': 'NULL'
                \, '$UNDEFINED': ''
                \, '$INDENT_HELPER': ''
                \, '$ELSESTYLE': ' '
                \, '$BRACKETSTYLE': ""})

" ================================= Snippets ===================================
" Loop
XPTemplateDef

XPT while hint=while\ (\ ..\ )\ {\ ..\ }
while (`condition^) `$BRACKETSTYLE^{
  `_^
}

..XPT

XPT forUp hint=for\ (..;..;++)
for ($`var^i^ = `initialValue^; $`var^ < `endValue^; $`var^++) `$BRACKETSTYLE^{
  `_^
}

..XPT

XPT forDown hint=for\ (..;..;--)
for ($`var^i^ = `initialValue^; $`var^ >= `endValue^0^; $`var^--) `$BRACKETSTYLE^{
  `_^
}

..XPT

XPT forEach hint=foreach\ (..\ as\ ..)\ {..}
foreach ($`var^ as $`key^key^) `$BRACKETSTYLE^{
  `_^
}

..XPT

XPT forEachAss hint=foreach\ (..\ as\ ..\ =>\ ..)\ {..}
foreach ($`var^ as $`key^key^ => $`value^value^) `$BRACKETSTYLE^{
  `_^
}

..XPT

" Condition
XPT switch hint=switch\ (..)\ {case..}
switch ($`var^) `$BRACKETSTYLE^{
  case `val^ :
    `_^
    break;
  `...^
  case `val^ :
    `__^
    break;
  `...^ 
  `default...^default:
    \`___\^^^
}

..XPT


XPT try hint=try\ {...}\ catch\ {...}
try `$BRACKETSTYLE^{
  `_^
}
catch (`exception^) `$BRACKETSTYLE^{
  `__^  
}

..XPT

" Begin the Doc
XPT php hint=<?php\ ...\ ?>
<?php `_^ ?>

XPT phpp hint=<?php\ /**/...\ ?>
<?php 
// $Id$
  
/**
  * @file
  *
  * `description^
  */

`body^

?>

" - Declaration

XPT globals hint="$GLOBALS["..."];"
$GLOBALS[`var^]

..XPT

XPT static hint="static $var;"
static $`varName^;

..XPT

XPT interface hint=interface\ ..\ {\ ..\ }
interface `interfaceName^ `$BRACKETSTYLE^{
  `_^
}

..XPT

" Functions
XPT function hint=function\ (..,\ ..)\ {..}
function `funName^($`var^`...^, $\`var\^\`...\^^^) `$BRACKETSTYLE^{
  `body^
}

..XPT

XPT dumpVar hint=var_dump\ (..);
print '<pre>'; var_dump($`var^); print '</pre>';

..XPT

XPT include hint=include\ (..);
include('`fileName^');

..XPT

XPT includeOnce hint=include_once\ (..);
include_once('`fileName^');

..XPT

"Aggiungere qualche campo a mail
XPT mail hint=mail\ (..)
$mail_to = '`destId^@`destDomain^';
$mail_subject = '`subject^';
$mail_body =<<<EOF
`body^
EOF;
$mail_headers = "From: `sourceId^@`sourceDomain^\\r\\n".
  `reply...^"Reply-To: \`replyId\^@\`replyDomain\^\\r\\n".^^
  `xmailer...^"X-Mailer: \`mailer\^"^^`
  `^;^^
mail($mail_to, $mail_subject, $mail_body, $mail_headers);

..XPT
